package com.credit.management.system.generator.dao;

import com.credit.management.system.model.Contract;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface ContractMapper {
    @Delete({
        "delete from contract",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into contract (id, project_id, ",
        "sum, date, state, ",
        "repayment_method)",
        "values (#{id,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, ",
        "#{sum,jdbcType=BIGINT}, #{date,jdbcType=DATE}, #{state,jdbcType=BIGINT}, ",
        "#{repaymentMethod,jdbcType=BIGINT})"
    })
    int insert(Contract record);

    int insertSelective(Contract record);

    @Select({
        "select",
        "id, project_id, sum, date, state, repayment_method",
        "from contract",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.credit.management.system.generator.dao.ContractMapper.BaseResultMap")
    Contract selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Contract record);

    @Update({
        "update contract",
        "set project_id = #{projectId,jdbcType=BIGINT},",
          "sum = #{sum,jdbcType=BIGINT},",
          "date = #{date,jdbcType=DATE},",
          "state = #{state,jdbcType=BIGINT},",
          "repayment_method = #{repaymentMethod,jdbcType=BIGINT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Contract record);
}